Skip to content

Feature aichat 20250730 and new plugin aiimage #1187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

guohuiyuan
Copy link
Contributor

No description provided.

)

// Storage 管理画图配置存储
type Storage struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private

)

func init() {
if err := os.MkdirAll("data/aiimage", 0755); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

用PrivateDataFolder就够了。

if err := os.MkdirAll("data/aiimage", 0755); err != nil {
panic(err)
}
if err := sdb.db.Open(time.Hour * 24); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在触发功能时懒加载,参考其他插件的getdb函数。

}

// ImageConfig 存储AI画图配置信息
type ImageConfig struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private,下同。

sdb.RLock()
defer sdb.RUnlock()
cfg := ImageConfig{}
_ = sdb.db.Find("config", &cfg, "WHERE id = 1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无效的封装。应当是

sdb.getConfig() // return imageConfig

然后在sdb.getConfig中上锁。锁不要暴露给调用者。其他位置同理。

Comment on lines 90 to 98
reqData := map[string]interface{}{
"model": cfg.ModelName,
"prompt": prompt,
"image_size": "1024x1024",
"batch_size": 4,
"num_inference_steps": 20,
"guidance_scale": 7.5,
}
reqBytes, _ := json.Marshal(reqData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reqData := map[string]interface{}{
"model": cfg.ModelName,
"prompt": prompt,
"image_size": "1024x1024",
"batch_size": 4,
"num_inference_steps": 20,
"guidance_scale": 7.5,
}
reqBytes, _ := json.Marshal(reqData)
reqBytes, _ := json.Marshal(map[string]interface{}{
"model": cfg.ModelName,
"prompt": prompt,
"image_size": "1024x1024",
"batch_size": 4,
"num_inference_steps": 20,
"guidance_scale": 7.5,
})

reqBytes, _ := json.Marshal(reqData)

// 发送API请求
data, err := web.RequestDataWithHeaders(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个🉑放AnimeAPI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api不固定暂时先别放那边

@fumiama
Copy link
Member

fumiama commented Aug 15, 2025

还有就是起个好点的PR名字,如

feat: add new plugin `aiimage`

@guohuiyuan guohuiyuan changed the title Feature aichat 20250730 Feature aichat 20250730 and add new plugin aiimage Aug 16, 2025
@guohuiyuan guohuiyuan changed the title Feature aichat 20250730 and add new plugin aiimage Feature aichat 20250730 and new plugin aiimage Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants